home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 March
/
CMCD0305.ISO
/
Software
/
Shareware
/
Utilitare
/
emu
/
Emu8086_Setup_307c.exe
/
{app}
/
Samples
/
stack.asm
< prev
next >
Wrap
Assembly Source File
|
2002-08-02
|
980b
|
71 lines
; This sample shows how the
; stack works. Click "Stack"
; button in emulator to see
; the contents of the stack.
#MAKE_COM#
; This code does nothing
; useful, except printing
; "Hi" in the end.
; COM file is loaded at 100h
; prefix:
ORG 100h
MOV AX, 1234h
PUSH AX
MOV DX, 5678h
PUSH DX
POP BX
POP CX
; function call pushes
; IP value of the next
; instruction:
CALL tfunc
MOV AX, 7890h
PUSH AX
POP BX
; A typical use of
; stack is to set segment
; registers.
; set DS to video
; memory segment:
MOV AX, 0B800h
PUSH AX
POP DS
; print "Hi":
MOV [170h], 'H'
MOV [172h], 'i'
; color attribute for 'H'
MOV [171h], 11001110b
; color attribute for 'i'
MOV [173h], 10011110b
RET
; the test procedure:
tfunc PROC NEAR
XOR BX, BX
XOR CX, CX
; here we "pop" the IP
; value:
RET
tfunc ENDP
END